//
//  ZTTabBarViewController.m
//  zhibo8
//
//  Created by zzt on 16/11/19.
//  Copyright © 2016年 zzt. All rights reserved.
//

#import "ZTTabBarViewController.h"
#import "ZTNavigationViewController.h"
#import "ZTDiscoveryViewController.h"
#import "ZTDataViewController.h"
//#import "ZTMenuTableViewController.h"
#import "ZTHomePzgeViewController.h"
#import "ZTVideoTableViewController.h"
#import "ZTNewsViewController.h"

@interface ZTTabBarViewController ()

@end

@implementation ZTTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //1.添加子控制器
    [self setupChildViewController];
    
    //2.设置tabBar上按钮内容
    [self setupTabbarButton];
}

#pragma mark - 添加子控制器
- (void)setupChildViewController {
    
    //首页
    ZTHomePzgeViewController *menuV = [[ZTHomePzgeViewController alloc]init];
    ZTNavigationViewController *nav1 = [[ZTNavigationViewController alloc]initWithRootViewController:menuV];
    [self addChildViewController:nav1];
    
    //视频
    ZTVideoTableViewController *videoV = [[ZTVideoTableViewController alloc]init];
    ZTNavigationViewController *nav2 = [[ZTNavigationViewController alloc]initWithRootViewController:videoV];
    [self addChildViewController:nav2];
    
    //新闻
    ZTNewsViewController *newsV = [[ZTNewsViewController alloc]init];
    ZTNavigationViewController *nav3 = [[ZTNavigationViewController alloc]initWithRootViewController:newsV];
    [self addChildViewController:nav3];
    
    //数据
    ZTDataViewController *dataV = [[ZTDataViewController alloc]init];
    ZTNavigationViewController *nav4 = [[ZTNavigationViewController alloc]initWithRootViewController:dataV];
    [self addChildViewController:nav4];
    
    //发现
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"ZTDiscoveryViewController" bundle:nil];
    // 加载箭头指向的控制器
    ZTDiscoveryViewController *discoveryV = [storyboard instantiateInitialViewController];
    ZTNavigationViewController *nav5 = [[ZTNavigationViewController alloc] initWithRootViewController:discoveryV];
    // initWithRootViewController => push
    [self addChildViewController:nav5];
}

#pragma mark - 设置button按钮的内容
- (void)setupTabbarButton {
    
    //主页
    UIViewController *vc0 = self.childViewControllers[0];
    vc0.tabBarItem.image = [UIImage imageNamed:@"bar_zhibo"];
    vc0.tabBarItem.selectedImage = [UIImage imageNamed:@"bar_zhiboed"];
    vc0.tabBarItem.title = @"主页";
    
    //视频
    UIViewController *vc1 = self.childViewControllers[1];
    vc1.tabBarItem.image = [UIImage imageNamed:@"bar_video"];
    vc1.tabBarItem.selectedImage = [UIImage imageNamed:@"bar_videoed"];
    vc1.tabBarItem.title = @"视频";
    
    //新闻
    UIViewController *vc2 = self.childViewControllers[2];
    vc2.tabBarItem.image = [UIImage imageNamed:@"bar_news"];
    vc2.tabBarItem.selectedImage = [UIImage imageNamed:@"bar_newsed"];
    vc2.tabBarItem.title = @"新闻";
    
    //数据
    UIViewController *vc3 = self.childViewControllers[3];
    vc3.tabBarItem.image = [UIImage imageNamed:@"bar_shuju"];
    vc3.tabBarItem.selectedImage = [UIImage imageNamed:@"bar_shujued"];
    vc3.tabBarItem.title = @"数据";
    
    //发现
    UIViewController *vc4 = self.childViewControllers[4];
    vc4.tabBarItem.image = [UIImage imageNamed:@"bar_faxian"];
    vc4.tabBarItem.selectedImage = [UIImage imageNamed:@"bar_faxianed"];
    vc4.tabBarItem.title = @"发现";
    
}
@end
